/******************************************************************************
COPYRIGHT 2012   : ATECH
Project          : 
Source File Name : Slave_lin1_appl.h
Group            : SoftWare Team
Author           : 
Date First Issued: 12/18/2012                                                  
******************************************************************************/
#ifndef Slave_lin1_appl_h 
#define Slave_lin1_appl_h

/* #include */
#include "Slave_lin1_ldf.h"
#include "Slave_lin1_dtype.h"
/* Class definitions */
struct lin1_t_id_list
{
    l_u8   id;          /* ID */
    l_u8   dir;         /* direction */
    l_u8   *data_ptr;   /* array of data field */
    l_u8   length;      /* the length of data field */
    l_bool timeout_flag;/* master not send frame header */
    l_u16  timeout_time;
    l_bool transmitted_flag;
    l_bool received_flag;
};
/* typedef */
typedef enum
{
    LIN1_EVENT_RecieveSleepCommand = 0,
    LIN1_EVENT_RecievedSleepCommand,
    LIN1_EVENT_RecievedRemoteWakeUp,
    LIN1_EVENT_RecievedFrameHead
    
}LIN1_tenSystemEvent;

typedef struct
{     
    l_bool boRecieveSleepCommand;
    l_bool boRecievedSleepCommand;
    l_bool boRecievedRemoteWakeUp;
    l_bool boRecievedFrameHead; 
                
}LIN1_tstSystemEvent;

typedef enum
{
    LIN1_IDLE,
    LIN1_HEAD,
    LIN1_TX,
    LIN1_RX
    
}LIN1_tenPhyState;

typedef enum
{
    LIN1_HEAD_SYNCH,
    LIN1_HEAD_ID
}LIN1_tenHeadState;

typedef enum
{
    LIN1_FLAG_Transmitted = 0,
    LIN1_FLAG_Received,
    LIN1_FLAG_Timeout,

}LIN1_tenFlagType;

typedef enum
{
    LIN1_LD_QUEUE_EMPTY = 0,
    LIN1_LD_QUEUE_AVAILABLE,
    LIN1_LD_QUEUE_FULL,
    LIN1_LD_TRANSMIT_ERROR,
    
}LIN1_tenRawTxStatus;

typedef enum
{
    LIN1_LD_NO_DATA = 0,
    LIN1_LD_DATA_AVAILABLE,
    LIN1_LD_RECEIVE_ERROR,
    
}LIN1_tenRawRxStatus;
/* arrays */
/* "Slave_lin1_sil2.c" arrays */
extern l_u8 LIN1_ID0_Frame[LIN1_ID0_Frame_LENTH];
extern l_u8 LIN1_ID1_Frame[LIN1_ID1_Frame_LENTH];
extern l_u8 LIN1_ID2_Frame[LIN1_ID2_Frame_LENTH];
extern l_u8 LIN1_ID3_Frame[LIN1_ID3_Frame_LENTH];
extern l_u8 LIN1_ID4_Frame[LIN1_ID4_Frame_LENTH];
extern l_u8 LIN1_ID5_Frame[LIN1_ID5_Frame_LENTH];
extern l_u8 LIN1_ID6_Frame[LIN1_ID6_Frame_LENTH];
extern l_u8 LIN1_ID7_Frame[LIN1_ID7_Frame_LENTH];
extern l_u8 LIN1_ID8_Frame[LIN1_ID8_Frame_LENTH];
extern l_u8 LIN1_ID9_Frame[LIN1_ID9_Frame_LENTH];
extern l_u8 LIN1_ID10_Frame[LIN1_ID10_Frame_LENTH];
extern l_u8 LIN1_ID11_Frame[LIN1_ID11_Frame_LENTH];
extern l_u8 LIN1_ID12_Frame[LIN1_ID12_Frame_LENTH];
extern l_u8 LIN1_ID13_Frame[LIN1_ID13_Frame_LENTH];
extern l_u8 LIN1_ID14_Frame[LIN1_ID14_Frame_LENTH];
extern l_u8 LIN1_ID15_Frame[LIN1_ID15_Frame_LENTH];
extern l_u8 LIN1_ID16_Frame[LIN1_ID16_Frame_LENTH];
extern l_u8 LIN1_ID17_Frame[LIN1_ID17_Frame_LENTH];
extern l_u8 LIN1_ID18_Frame[LIN1_ID18_Frame_LENTH];
extern l_u8 LIN1_ID19_Frame[LIN1_ID19_Frame_LENTH];
extern l_u8 *LIN1_Frame_Ptr[LIN1_ID_TABLE_SIZE];
extern struct lin1_t_id_list LIN1_ID_Table[LIN1_ID_TABLE_SIZE];

extern l_u8 LIN1_Rx_Buffer[1+LIN1_DATASEND_MAX_LEN];
extern l_u8 LIN1_Tx_Buffer[1+LIN1_DATAREQUEST_MAX_LEN];
/* variables */
/* "Slave_lin1_sil2.c" variables */
extern l_u8 LIN1_CurrIdIndex;
/* "Slave_lin1_dll1.c" variables */
extern LIN1_tenPhyState LIN1_enPhyState;
/* "Slave_lin1_dll2.c" variables */
extern l_u8 LIN1_BytesToSent;
extern l_u8 LIN1_BytesToReceived;
extern l_u8 LIN1_Sleep_Frame_Rx_Buffer[1+SLEEP_FRAME_LENTH];

#endif